package ucm;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import model.Database_Model;
import model.User_Model;

public class UCLoginStatus {
    private String name;
    private User_Model user;

    public UCLoginStatus(view.Air_Login log) {
        this.user = log.getUserModel();

        this.name = user.getUsername();
    }

    public String run(){
        boolean user_exist = true;

        try {
            Connection con = new Database_Model().getConnection();
            Statement stmt = con.createStatement();

            String User = "select * from user where Name='" + this.name + "'";
            ResultSet res = stmt.executeQuery(User);
            if (res.first()&&!res.wasNull()) {
                return res.getString("status");
            } else {
                return null;
            }
        } catch (SQLException e) {
            e.printStackTrace();
            return null;
        }
    }

}
